import { defineStore } from 'pinia'
import { ref } from 'vue'

/**
 * 对话
 */

const useDialogue = defineStore(
  'dialogue',
  () => {
    // 弹窗
    const dialogVisible = ref(false)
    const setDialogVisible = (val) => {
      dialogVisible.value = val
    }

    const activePersonObj = {
      customerName: '',
      customerId: null
    }
    // 当前对话人
    const activePerson = ref(activePersonObj)
    const setActivePerson = (val) => {
      activePerson.value = val
    }

    // 重置
    const reset = () => {
      activePerson.value = activePersonObj
    }

    return {
      dialogVisible,
      setDialogVisible,
      activePerson,
      setActivePerson,
      reset
    }
  },
  {
    persist: {
      enabled: false,
      strategies: [
        {
          storage: localStorage
        }
      ]
    }
  }
)

export default useDialogue
